package com.sale24h.data;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class clsNhomHang
{
	private String maNhom;
	private String tenNhom;
	private String maQuay;
	private List<clsMatHang> lstMatHangs;
	
	public String getMaNhom()
	{
		return maNhom;
	}
	public void setMaNhom(String maNhom)
	{
		this.maNhom = maNhom;
	}
	public String getTenNhom()
	{
		return tenNhom;
	}
	public void setTenNhom(String tenNhom)
	{
		this.tenNhom = tenNhom;
	}
	public String getMaQuay()
	{
		return maQuay;
	}
	public void setMaQuay(String maQuay)
	{
		this.maQuay = maQuay;
	}
	
	public clsNhomHang()
	{
		setLstMatHangs(new ArrayList<clsMatHang>());
	}
	public void InitFromJSON(JSONObject jnh) throws JSONException
	{
		this.maNhom=jnh.getString("manhom");
		this.tenNhom=jnh.getString("tennhom");
		this.maQuay=jnh.getString("maquay");
		
		//apply ds mat hangs
		String tag_mathangs="mathangs";
		JSONArray jamh=jnh.getJSONArray(tag_mathangs);
		
		for (int i = 0; i < jamh.length(); i++)
		{
			JSONObject jmh=jamh.getJSONObject(i);
			clsMatHang clsmh=new clsMatHang();
			clsmh.InitFromJSON(jmh);
			
			getLstMatHangs().add(clsmh);
		}
		
	}
	@Override
	public String toString()
	{
		return this.tenNhom;
	}
	public List<clsMatHang> getLstMatHangs()
	{
		return lstMatHangs;
	}
	public void setLstMatHangs(List<clsMatHang> lstMatHangs)
	{
		this.lstMatHangs = lstMatHangs;
	}

}
